#include "parser/chat.h"

#include <QtCore>

QRegExp ParserChat::regexp("^(\\w+)(?:\\([^)]+\\))?\\s+tells you:\\s+(.+)$");

ParserChat::ParserChat()
{
}

bool ParserChat::needProcessLine( const QString& str )
{
  bool result = false;
  int pos = 0;
  if ( regexp.indexIn( str, pos ) != -1 ) result = true;
  return result;
}

void ParserChat::processLine( const QString& str )
{
  int pos = 0;
  qDebug() << "ParserChat processing line:" << str;
  if ( (pos = regexp.indexIn( str, pos )) != -1 ) {
    QString login = regexp.cap(1);
    QString phrase = regexp.cap(2);
    emit chatPhrase( login, phrase );
  }
}
